import { Router } from 'express'
import { find } from '../../db/dao'
import { STUDENT } from '../../db/model'

const router = Router()

router.get('/list', (req, res) => {
  const { account } = req.query
  const id = account ? find(STUDENT, { account }) : find(STUDENT)
  id.then(data => {
    if (data.length === 0) {
      return res.status(403).send('用户不存在')
    }
    res.status(200).json(data)
  }).catch(() => {
    res.status(500).end()
  })
})

export default router
